package com.cwd.arm.common.query;

import com.cwd.arm.common.util.SqlUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

/**
 * Created by yan on 21-11-11.
 */
@Data
public class PageQuery {

    @ApiModelProperty(value = "分页数量")
    protected int pageSize = 20;

    @ApiModelProperty(value = "当前页")
    protected int currentPage = 1;

    @ApiModelProperty(value = "排序字段", example = "createTime")
    protected String sortField;

    @ApiModelProperty(value = "排序规则", example = "DESC或者ASC")
    protected String orderByType = "DESC";

//    private String sortColumn;

    public String getSortColumn() {
        if(StringUtils.isEmpty(sortField)){
            return "create_time";
        }
        if(sortField.equals("userName")){
            return "user_id";
        }
        return SqlUtil.toColumn(sortField);
    }

}
